Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
vary
rewrite in TypeScript with ESM and CommonJS targets
Manipulate the HTTP Vary header
pnpm i es-vary
import { vary, append } from 'es-vary'
vary(res, field)
Adds the given header field
to the Vary
response header of res
.
This can be a string of a single field, a string of a valid Vary
header, or an array of multiple fields.
This will append the header if not already listed, otherwise leaves it listed in the current location.
vary(res, 'Origin')
append(header, field)
Adds the given header field
to the Vary
response header string header
.
This can be a string of a single field, a string of a valid Vary
header,
or an array of multiple fields.
This will append the header if not already listed, otherwise leaves it listed in the current location. The new header string is returned.
// Get header string appending "Origin" to "Accept, User-Agent"
append('Accept, User-Agent', 'Origin')
import { createServer } from 'http'
import { vary } from 'es-vary'
createServer((req, res) => {
// about to user-agent sniff
vary(res, 'User-Agent')
const ua = req.headers['user-agent'] || ''
const isMobile = /mobi|android|touch|mini/i.test(ua)
// serve site, depending on isMobile
res.setHeader('Content-Type', 'text/html')
res.end('You are (probably) ' + (isMobile ? '' : 'not ') + 'a mobile user')
})
MIT © v1rtl
FAQs
vary rewrite in TypeScript with ESM and CommonJS targets
The npm package es-vary receives a total of 41,502 weekly downloads. As such, es-vary popularity was classified as popular.
We found that es-vary demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.